ostree-prepare-root: Add test that overlayfs over /usr works.
authorWilliam Manley <will@williammanley.net>
Sun, 31 Jul 2016 21:19:13 +0000 (22:19 +0100)
committerAtomic Bot <atomic-devel@projectatomic.io>
Tue, 2 Aug 2016 19:07:25 +0000 (19:07 +0000)
Closes: #403
Approved by: cgwalters

tests/test-switchroot.sh

index 03e828082ff941d5d90084ad850d645153da3d56..17085140c6e152af115c4015a4dd3f84d59b8daf 100755 (executable)
@@ -26,6 +26,11 @@ setup_rootfs() {
        cp -r "$1/bin" "$1/ostree/deploy/linux/deploy/1334/"
 }
 
+setup_overlay() {
+       mkdir -p "$1/ostree/deploy/linux/deploy/1334/.usr-ovl-work" \
+                "$1/ostree/deploy/linux/deploy/1334/.usr-ovl-upper"
+}
+
 enter_fs() {
        cd "$1"
        mkdir testroot
@@ -52,6 +57,7 @@ find_in_env() {
                        && echo "/sysroot/usr is writable" \
                        || echo "/sysroot/usr is not writable"
                EOF
+       (cd $tmpdir && find) >permanent_files
        rm -rf "$tmpdir"
 }
 
@@ -95,13 +101,28 @@ test_that_prepare_root_sets_root_up_correctly_with_no_initrd() {
        echo "ok ostree-prepare-root sets root up correctly with no initrd"
 }
 
+setup_no_initrd_with_overlay() {
+       setup_no_initrd_env "$1"
+       setup_overlay "$1"
+}
+
+test_that_prepare_root_provides_overlay_over_usr_if__usr_ovl_work_exists() {
+       find_in_env setup_no_initrd_with_overlay >files
+
+       grep -qx "/usr is writable" files
+       grep -qx "./ostree/deploy/linux/deploy/1334/.usr-ovl-upper/usr_writable" permanent_files
+       ! grep -qx "./ostree/deploy/linux/deploy/1334/usr/usr_writable" permanent_files || exit 1
+       echo "ok ostree-prepare-root sets root up correctly with writable usr overlay"
+}
+
 # This script sources itself so we only want to run tests if we're the parent:
 if [ "${BASH_SOURCE[0]}" = "${0}" ]; then
        . $(dirname $0)/libtest.sh
        unshare -m true || \
            skip "this test needs to set up mount namespaces, rerun as root"
 
-       echo "1..2"
+       echo "1..3"
        test_that_prepare_root_sets_sysroot_up_correctly_with_initrd
        test_that_prepare_root_sets_root_up_correctly_with_no_initrd
+       test_that_prepare_root_provides_overlay_over_usr_if__usr_ovl_work_exists
 fi